package com.abc.config;

import com.abc.service.WarpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 自动配置类
 */
@Configuration
@ConditionalOnClass(WarpService.class)
@EnableConfigurationProperties(WarpServiceProperties.class)
public class WarpServiceAutoConfiguration {

    @Autowired
    private WarpServiceProperties properties;


    @Bean
    @ConditionalOnClass
    public WarpService warpService(){
        return new WarpService(properties.getPrefix(), properties.getSuffix());
    }

//    @Bean
//    @ConditionalOnProperty(name = "warp.service.enabled", havingValue = "true", matchIfMissing = true)
//    public WarpService warpService2(){
//        return new WarpService(properties.getPrefix(), properties.getSuffix());
//    }
}
